package com.xsomnus.java_basic.juc.exceptions;

import java.util.concurrent.ThreadFactory;

/**
 * @author @叶小夏
 * @since 2019/7/29 0029 17:15
 * - 才需学也,学需静也/非淡泊无以明志，非宁静无以致远
 */
public class HandlerThreadFactory implements ThreadFactory {

    @Override
    public Thread newThread(Runnable r) {
        System.out.println("create thread");
        Thread t = new Thread(r);
        System.out.println("为线程设置一个异常捕获");
        t.setUncaughtExceptionHandler(new MyUncaughtExceptionHandler());
        return t;
    }
}
